/**
 * Created by Veronica on 2017/3/19.
 */
package classdemo2;
class Person{
    private int age;
    private String name;
    public  int getAge(){
        return age;
    }
    public  void setAge( int a) {
        if (a >= 0 && a < 150) {
            age = a;
        }
    }
    public String getName(){
        return name;
    }
    public void setName(String name){
        this.name = name;
    }
    public void tell(){
//        get是得到
        System.out.println("年龄:"+getAge()+"  "+"姓名："+getName());
    }

}
public class ClassDemo02 {
    public static void main(String[] args) {
        Person per = new Person();
//        per.age = -30;
//        per.name = "张三";
        per.setAge(30);/*设置*/
        per.setName("张三");
        per.tell();
    }
}
